package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishItemVO;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SetmealMapper {
    @Select("select count(id) from sky_take_out.setmeal where category_id = #{categoryId}")
    Integer countByCategoryId(Long id);
    @Options(useGeneratedKeys = true,keyProperty = "id")
    @Insert("insert into sky_take_out.setmeal(category_id, name, price, status, description, image, create_time, update_time, create_user, update_user) " +
            "values (#{categoryId},#{name},#{price},#{status},#{description},#{image},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    @AutoFill(type = OperationType.INSERT)
    void save(Setmeal setmeal);

    List<SetmealVO> getpage(SetmealPageQueryDTO setmealPageQueryDTO);
    @Select("select * from sky_take_out.setmeal where id=#{id}")
    Setmeal getid(Long id);
    @Delete("delete from sky_take_out.setmeal where id=#{id}")
    void clearid(Long id);
    @AutoFill(type = OperationType.UPDATE)
    void update(Setmeal setmeal);

    List<Setmeal> list(Setmeal setmeal);
    @Select("select ds.name,ds.copies,d.image,d.description from setmeal_dish ds left join dish d on ds.dish_id = d.id where ds.setmeal_id=#{setmealId}")
    List<DishItemVO> getDishItemBySetmealId(Long id);

    @Select("select * from setmeal")
    List<Setmeal> getsetmeals();
}
